#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>

int main(void)
{
    int pid = 0;
    
    printf("parrent = %d, ppid = %d, pgid = %d\n", getpid(), getppid(), getpgrp());
    
    if( (pid = fork()) > 0 ) {
        int r = setpgid(pid, pid);
        printf("new: %d, r = %d\n", pid, r);
    } else if( pid == 0 ) {
        setpgid(pid, pid);
        sleep(1);
        printf("child = %d, ppid = %d, pgid = %d\n", getpid(), getppid(), getpgrp());
    } else {
        printf("fork error...\n");
    }  
    
    sleep(60);

    return 0;
}
